What Every Web Developer Should Know About HTTP (OdeToCode Programming Series Book 1) by K. Scott Allen
Author:K. Scott Allen [Allen, K. Scott]
Language: eng
Format: epub
Publisher: OdeToCode LLC
Published: 2012-02-06T06:00:00+00:00
Fortunately, parallel connections are not the only performance optimization.
Persistent Connections
In the early days of the web, a web browser would open and close a connection for each individual HTTP transaction. This implementation was per HTTP's idea of being a stateless protocol, meaning the server does not have to remember the state of any client that connects. A server doesn’t have to remember, for example, the preferred language of a client. All the information a server needs to know about a client will be inside each incoming HTTP request message, including the client’s preferred language.
As the number of requests per page grew, so did the overhead generated by TCP handshakes and the in-memory data structures required to establish each TCP socket. To reduce this overhead and improve performance, the HTTP 1.1 specification suggests that clients and servers should implement persistent connections and make persistent connections the default type of connection.
A persistent connection stays open after the completion of one request-response transaction. This behavior leaves a browser with an already open socket it can use to continue making future requests to the server without the overhead of opening a new socket.
Persistent connections also avoid the slow start strategy that is part of TCP congestion control, making persistent connections perform better over time. The slow start strategy of TCP helps to avoid sending more data than a network can handle by starting transmission at a slow rate and gradually increasing the speed if the network is proving itself capable.
Persistent connections reduce memory usage, reduce CPU usage, reduce network congestion, reduce latency, and generally improve the response time of a page. However, like everything in the world of computers there is a trade-off.
As mentioned earlier, a server can only support a finite number of incoming connections. The exact number depends on the amount of memory available, the configuration of the server software, the performance of the application, and many other variables. It is difficult to give an exact number, but if you talk about supporting thousands of concurrent connections on a single machine, you'll want to start testing to see if the machine and the application will support the load.
Many servers have a default configuration to limit the maximum number of concurrent connections far below the point where the server will fail. The configuration is a security measure to help prevent denial of service (DoS) attacks. A malicious person can initiate a DoS attack by creating programs that open thousands of persistent connections to a server. By overwhelming the server with connections, the malicious person can inhibit the server from responding to real customers.
Thinking along the lines of a security vulnerability, we also have to wonder how long a persistent connection should stay open. In a world where all computers had an infinite amount of memory, CPU power, and network bandwidth, the persistent connection could stay open for as long as the web browser was running. However, because a server only supports a finite number of connections, most web servers will close a persistent connection if it is idle for some period.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Fifty Quick Ideas to Improve Your Tests by Gojko Adzic David Evans and Tom Roden(844)
Hands-On RESTful Web Services with ASP.NET Core 3 by Samuele Resca(703)
CSS 3 Visual Learning Guide: a comprehensive example set for getting up to speed fast by Ludo Mike(529)
PHP 7 Solutions by David Powers(434)
React js: The Ultimate Beginner's Guide to Learn React js Programming Step by Step - 2020 by Peterson Kathleen(427)
Getting Started with the Internet of Things by Pfister Cuno(383)
Beginning Git and GitHub by Mariot Tsitoara(379)
HTML 5 Visual Learning Guide: a comprehensive example set for getting up to speed fast by Ludo Mike(365)
Getting a Coding Job For Dummies by Nikhil Abraham(363)
Programming PHP by Kevin Tatroe Peter MacIntyre & Rasmus Lerdorf(322)
Magento 2 Development Cookbook by Bart Delvaux(321)
Programming PHP by Kevin Tatroe(303)
Creating Data-Driven Web Sites by Bob Terrell(302)
Full Stack Serverless by Nader Dabit(295)
Manifesto Comunista by Friedrich Engels(294)
Getting Started with OAuth 2.0 by Boyd Ryan(290)
Practical Oracle JET by Daniel Curtis(290)
gRPC by Kasun Indrasiri(278)
Building Web Applications with Erlang by Zachary Kessin(274)
